const ArticlecateModel = require('./model/articlecate');
const koa = require('koa');
const app = new koa();
const UserModel = require('./model/user');
const ArticleModel = require('./model/article');
/* 查询文章的信息 并显示文章的分类  作者的信息 */
var data = ArticleModel.aggregate([
    {$lookup:{
        from:"articlecate",
        localField:'cid',
        foreignField:'_id',
        as:"details"
    }},
    {
        $lookup:{
            from:"user",
            localField:'author_id',
            foreignField:'_id',
            as:'userInfo'
        }
    }
])
app.use(async (ctx,next)=>{
    var res = await data;
    ctx.body = res
})
app.listen(8080)